#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
	int a,b,d;
	cin>>a>>b>>d;
	int num = a+b;
    if(num==0)cout<<0;
	vector<int> ans;
	while(num){
		ans.push_back(num%d);
		num /= d;
	}
	for(int i=ans.size()-1;i>=0;i--){
		cout<<ans[i];
	}
	return 0;
}
